import { userApi } from '/api/user'

Page({
  data: {
    data: {},
    price: '',
  },
  async onLoad(option) {
    if (option.orderId) {
      const data = await userApi.withdrawById((option.orderId as unknown) as number)
      this.setData({
        data,
        price: (data.value / 100).toFixed(2),
      })
    } else {
      const pages = getCurrentPages()
      const lastpage = pages[pages.length - 2]
      const data = lastpage.data.list[option.index ?? 0]
      this.setData({
        data,
        price: (data.value / 100).toFixed(2),
      })
    }
  },
})
